package com.pbking.facebook.delegates.data
{
	import com.pbking.facebook.Facebook;
	import com.pbking.facebook.delegates.FacebookDelegate;
	
	/**
	 * delegate for calling data.getObject  
	 * 
	 * @author sol wu
	 */
	public class GetObjectDelegate extends FacebookDelegate
	{
		public var values:Array;
		
		public function GetObjectDelegate(facebook:Facebook, objid:Number, propNames:Array = null)
		{
			super(facebook);
			if (objid) { fbCall.setRequestArgument("obj_id", objid.toString()); }
			
			// not yet tested.  
			if (propNames) { fbCall.setRequestArgument("prop_names", propNames.join(",")); }

			fbCall.post("facebook.data.getObject");
		}
		
		override protected function handleResult(result:Object):void
		{
			// An array of the values only (not the names) of specified properties of the object.
			values = [];
			
			for each(var val:Object in result)
			{
				values.push(val);
			} 
		}
		
	}
}